#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>

int main(void)
{
    int pid = 0;
    
    printf("parrent = %d, ppid = %d, pgid = %d\n", getpid(), getppid(), getpgrp());
    
    if( (pid = fork()) > 0 ) {
        int r = 0;
        
        sleep(1);
        
        r = setpgid(pid, pid);
        printf("new: %d, r = %d\n", pid, r);
    } else if( pid == 0 ) {
        char* out = "./helloworld.out";
        char* const ps_argv[] = {out, NULL};
        char* const ps_envp[] = {"PATH:/bin/usr/bin", NULL};
        execve(out, ps_argv, ps_envp);
    } else {
        printf("fork error...\n");
    }  
    
    sleep(60);
    return 0;
}

